<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .fl {
            float: left;
        }

        .clearfix::after {
            content: "";
            display: none;
            clear: both;
        }

        ul li {
            list-style: none;
        }

        .title {
            width: 300px;
            height: 100px;
            border: 1px solid #ccc;
        }

        .title ul li {
            width: 50px;
            line-height: 50px;
            float: left;
            padding: 10px;
        }

        .title .current {
            background-color: #f60;
        }

        .content {
            width: 500px;
            height: 400px;
            background-color: pink;
        }


        .content ul {
            display: none;
        }

        .content .active {
            display: block;
        }
    </style>
</head>

<body>
    <div class="title">
        <ul class="clearfix">
            <li>电子书</li>
            <li>电影</li>
            <li>电视剧</li>
        </ul>
    </div>
    <div class="content">
        <!-- 第一个内容 -->
        <ul class="active">
            <li>1</li>
            <li>2</li>
        </ul>
        <!-- 第二个内容 -->
        <ul>
            <li>3</li>
            <li>4</li>
        </ul>
        <!-- 第三个内容 -->
        <ul>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
    <script>
        var contentsUl = document.querySelectorAll(".content >ul")
        console.log(contentsUl);
        var titleLis = document.querySelectorAll(".title ul li");
        for (let i = 0; i < titleLis.length; i++) {
            titleLis[i].addEventListener('mouseover', function () {
                for (let i = 0; i < titleLis.length; i++) {
                    titleLis[i].className = '';
                    contentsUl[i].className = "";
                }
                titleLis[i].className = 'current';
                contentsUl[i].className = "active";
            })
        }

    </script>
</body>

</html>